import React, {Component} from 'react';
import {Text, View, DeviceEventEmitter} from 'react-native';
import Header from "../components/Header";
import {Dropdown} from "react-native-material-dropdown";
import {MyStatusBar} from "../components/MyStatusBar";
import {options} from '../Global';
import {storage} from '../utils/storage';

class OptionsScreen extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        let fontSizeArray = [{value: '14'}, {value: '15'}, {value: '16'}, {value: '17'}, {value: '18'}, {value: '19'}, {value: '20'}];

        return (
            <View style={{flex: 1}} onLayout={this._onLayout}>
                <MyStatusBar backgroundColor="#f4511e"/>
                <Header
                    headerRight={null}
                    headerLeftOnPress={() => {
                        this.props.navigation.goBack();

                        // 返回刷新方法1
                        // const {goBack, state} = this.props.navigation;
                        // // 在登录页面,在goBack之前,将上个页面的方法取到,并回传参数,这样回传的参数会重走render方法
                        // state.params.callback(options.readerSettings.fontSize, options.readerSettings.lineHeight);
                        // goBack();

                    }}
                />

                <View style={{marginTop: 5, marginLeft: 5}}>
                    <Dropdown
                        label='字体大小'
                        value={options.readerSettings.fontSize}
                        data={fontSizeArray}
                        onChangeText={(value, index, data) => {
                            let fontSize = parseInt(value), lineHeight = parseInt(fontSize) + 6;
                            options.readerSettings.fontSize = fontSize;
                            options.readerSettings.lineHeight = lineHeight;
                        }}
                    />
                </View>
            </View>
        );
    }
}

export default OptionsScreen;